<?php

DisplayImage();
require("init.php");

$client = new client();
$ip = $client->get_user_ip();
$brownserType = addslashes($client->get_user_agent());
$brownserLanguage = $client->get_user_lang();
$userOs = $client->get_user_os();
$timeStamp = time();
if (isset($_REQUEST['m'])) {
	$str = $_REQUEST["m"];
	$r = explode(".",$str);
	
	$str = base64_decode($r[0]);
	$mArr = explode("|",$str);
//	$browserNumSql = "update template set brownserNum = brownserNum + 1 where id = ".$mArr[3]."";
//	$browserNumSql = "INSERT INTO template(id,brownserNum) VALUES ($mArr[3],1) ON DUPLICATE KEY UPDATE brownserNum = brownserNum + 1";
//	mysql_query($browserNumSql,$conn);
	$sql = "insert into openI(numId, ip, type, timeStamps, templateId, brownserType, brownserLanguage, os) values('".$mArr[0]."','".$ip."','".$mArr[1]."','".$timeStamp."',".$mArr[2].",'".$brownserType."','".$brownserLanguage."','".$userOs."')";
	echo $sql;
    $GLOBALS['db']->dbquery($sql);
	exit(0);
}
	
function DisplayImage()
{
	// open the file in a binary mode
	$name = 'images/track.gif';
	$fp = fopen($name, 'rb');

	// send the right headers
	header("Content-Type: image/gif");
	header("charset=utf-8");
	header("Content-Length: " . filesize($name));
	// dump the picture and stop the script
	//echo "adf";exit;
	fpassthru($fp);

}

?>